<template>
  <div>
    <h6 class="hLabel">主体信息</h6>
    <el-form-item label="商户类型" prop="merchantType">
      <div class="subjectTypeSwitch" style="width: 300px">
        <!-- 个体 -->
        <div
          :class="[
            sumbitForm.merchantType == '01'
              ? 'individuality'
              : 'active-individuality'
          ]"
          @click="switchType('01')"
          >企业</div
        >
        <!-- 企业 -->
        <div
          :class="[
            sumbitForm.merchantType == '06' ? 'active-enterprise' : 'enterprise'
          ]"
          @click="switchType('06')"
          >个人商户</div
        >

        <!-- 个人商户 -->
        <div
          :class="[
            sumbitForm.merchantType == '07' ? 'active-enterprise' : 'enterprise'
          ]"
          @click="switchType('07')"
          >个体工商户</div
        >
      </div>
    </el-form-item>
    <el-form-item label="商户名称" prop="name">
      <el-input
        v-model="sumbitForm.name"
        placeholder="请输入商户名称"
      ></el-input>
      <span>注意:[支付宝的账单名称,会显示此处的设置的商户简称]</span>
    </el-form-item>
    <el-form-item label="商户别名" prop="aliasName">
      <el-input
        v-model="sumbitForm.aliasName"
        placeholder="请输入商户别名"
      ></el-input>
      <span>注意:[支付宝的账单名称,会显示此处的设置的商户简称]</span>
    </el-form-item>
    <el-form-item label="进件mcc" prop="mcc">
      <el-cascader
        v-model="sumbitForm.mcc"
        placeholder="请填写进件mcc"
        :options="mccOptions"
        @change="handleChangeMcc"
        :props="{ expandTrigger: 'hover' }"
      ></el-cascader>
    </el-form-item>
    <el-form-item label="商户证件编号" prop="certNo">
      <el-input
        v-model="sumbitForm.certNo"
        :placeholder="
          sumbitForm.merchantType !== '06'
            ? '请选择营业执照号'
            : '请选择个人身份证号码'
        "
      ></el-input>
      <span
        >按商户类型的说明提供对应的证件编号 如果为企业
        个体工商户请输入营业执照号 个人商户的时候输入身份证号码</span
      >
    </el-form-item>

    <el-form-item label="营业执照名称" prop="certName">
      <el-input
        v-model="sumbitForm.certName"
        placeholder="请输入营业执照名称"
      ></el-input>
      <span>注意:[请填写营业执照的商家名称，2~110个字符,支持括号]</span>
    </el-form-item>

    <el-form-item label="营业执照省市区编号" prop="licenseCode">
      <regions-select
        v-model="sumbitForm.licenseCode"
        placeholder="请营业执照省市区编号"
        @input="(event) => regionsInput(event, 'licenseCode')"
      />
    </el-form-item>
    <el-form-item label="营业执照地址" prop="address">
      <el-input
        v-model="sumbitForm.address"
        placeholder="请输入营业执照地址"
      ></el-input>
    </el-form-item>

    <!-- 门头照片 -->
    <el-form-item label="门头照片" prop="outDoorImages">
      <el-upload
        action="#"
        ref="pictureUploadOutDoorImages"
        list-type="picture-card"
        :limit="5"
        :on-exceed="exceedFn"
        :on-change="
          (files, fileList) =>
            handleFileChange(files, fileList, 'outDoorImages')
        "
        :auto-upload="false"
      >
        <i slot="default" class="el-icon-download">
          <div style="font-size: 14px; margin-top: 20px" slot="default"
            >点击上传</div
          >
        </i>

        <div slot="file" slot-scope="{ file }">
          <img
            v-if="!isImageUrl"
            class="el-upload-list__item-thumbnail"
            :src="file.url"
            alt=""
          />

          <img
            v-if="isImageUrl"
            class="el-upload-list__item-thumbnail"
            :src="imageUrl"
            alt=""
          />
          <span class="el-upload-list__item-actions">
            <!-- 图片的预览 -->
            <span
              class="el-upload-list__item-preview"
              @click="handlePictureCardPreview(file)"
            >
              <i class="el-icon-zoom-in"></i>
            </span>
            <!-- 图片的下载 -->
            <span
              v-if="!disabled"
              class="el-upload-list__item-delete"
              @click="handleDownload(file)"
            >
              <i class="el-icon-download"></i>
            </span>
            <!-- 图片的移除 -->
            <span
              v-if="!disabled"
              class="el-upload-list__item-delete"
              @click="handleRemove(file, 'outDoorImages')"
            >
              <i class="el-icon-delete"></i>
            </span>
          </span>
        </div>
      </el-upload>
      <el-dialog :visible.sync="dialogVisible">
        <img width="100%" :src="dialogImageUrl" alt="" />
      </el-dialog>
      <span
        >注意:【门头照片必须要要与营业执照的名称相关，否则人工审核会失败】</span
      >
    </el-form-item>
    <!-- 办公环境 -->
    <el-form-item label="办公环境" prop="inDoorImages">
      <el-upload
        action="#"
        ref="pictureUploadInDoorImages"
        list-type="picture-card"
        :limit="5"
        :on-exceed="exceedFn"
        :on-change="
          (file, fileList) => handleFileChange(file, fileList, 'inDoorImages')
        "
        :auto-upload="false"
      >
        <i slot="default" class="el-icon-download">
          <div style="font-size: 14px; margin-top: 20px" slot="default"
            >点击上传</div
          >
        </i>

        <div slot="file" slot-scope="{ file }">
          <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
          <span class="el-upload-list__item-actions">
            <!-- 图片的预览 -->
            <span
              class="el-upload-list__item-preview"
              @click="handlePictureCardPreview(file)"
            >
              <i class="el-icon-zoom-in"></i>
            </span>
            <!-- 图片的下载 -->
            <span
              v-if="!disabled"
              class="el-upload-list__item-delete"
              @click="handleDownload(file)"
            >
              <i class="el-icon-download"></i>
            </span>
            <!-- 图片的移除 -->
            <span
              v-if="!disabled"
              class="el-upload-list__item-delete"
              @click="handleRemove(file, 'inDoorImages')"
            >
              <i class="el-icon-delete"></i>
            </span>
          </span>
        </div>
      </el-upload>
      <el-dialog :visible.sync="dialogVisible">
        <img width="100%" :src="dialogImageUrl" alt="" />
      </el-dialog>
      <span>注意:【办公环境如:餐饮店的照片、办公室、公司前台等照片...】</span>
    </el-form-item>

    <div class="fromSubmitTwo">
      <h6 class="hLabel">法人/负责人信息</h6>

      <el-form-item label="法人姓名" prop="legalName">
        <el-input
          placeholder="请输入法人姓名"
          v-model="sumbitForm.legalName"
          @change="inputFn"
        ></el-input>
      </el-form-item>
      <el-form-item label="法人身份证号" prop="legalCertNo">
        <el-input
          placeholder="请输入法人身份证号"
          v-model="sumbitForm.legalCertNo"
          show-password
        ></el-input>
      </el-form-item>
      <el-form-item label="联系人姓名" prop="contactName">
        <el-input
          placeholder="请输入联系人姓名"
          v-model="sumbitForm.contactName"
        ></el-input>
      </el-form-item>
      <el-form-item label="联系人电话" prop="contactMobile">
        <el-input
          placeholder="请输入联系人电话"
          v-model="sumbitForm.contactMobile"
        ></el-input>
      </el-form-item>
      <!-- 身份证正反面 -->
      <div class="positiveAndNegativeIDcards">
        <!-- 身份证正面 -->
        <el-form-item
          label="身份证正面"
          prop="certImage"
          class="positiveIDcards"
        >
          <el-upload
            action="#"
            ref="pictureUploadIdCertImage"
            :limit="1"
            :on-exceed="exceedFn"
            :on-change="
              (file, fileList) => handleFileChange(file, fileList, 'certImage')
            "
            list-type="picture-card"
            :auto-upload="false"
          >
            <i slot="default" class="el-icon-download">
              <div style="font-size: 14px; margin-top: 20px" slot="default"
                >点击上传</div
              >
            </i>

            <div slot="file" slot-scope="{ file }">
              <img
                class="el-upload-list__item-thumbnail"
                :src="file.url"
                alt=""
              />
              <span class="el-upload-list__item-actions">
                <!-- 图片的预览 -->
                <span
                  class="el-upload-list__item-preview"
                  @click="handlePictureCardPreview(file)"
                >
                  <i class="el-icon-zoom-in"></i>
                </span>
                <!-- 图片的下载 -->
                <span
                  v-if="!disabled"
                  class="el-upload-list__item-delete"
                  @click="handleDownload(file)"
                >
                  <i class="el-icon-download"></i>
                </span>
                <!-- 图片的移除 -->
                <span
                  v-if="!disabled"
                  class="el-upload-list__item-delete"
                  @click="handleRemove(file, 'certImage')"
                >
                  <i class="el-icon-delete"></i>
                </span>
              </span>
            </div>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="" />
          </el-dialog>
        </el-form-item>

        <!-- 身份证反面 -->
        <el-form-item label="身份证反面" prop="certImageBack">
          <el-upload
            action="#"
            list-type="picture-card"
            :limit="1"
            :on-exceed="exceedFn"
            ref="pictureUploadCertImageBack"
            :on-change="
              (file, fileList) =>
                handleFileChange(file, fileList, 'certImageBack')
            "
            :auto-upload="false"
          >
            <i slot="default" class="el-icon-download">
              <div style="font-size: 14px; margin-top: 20px" slot="default"
                >点击上传</div
              >
            </i>

            <div slot="file" slot-scope="{ file }">
              <img
                class="el-upload-list__item-thumbnail"
                :src="file.url"
                alt=""
              />
              <span class="el-upload-list__item-actions">
                <!-- 图片的预览 -->
                <span
                  class="el-upload-list__item-preview"
                  @click="handlePictureCardPreview(file)"
                >
                  <i class="el-icon-zoom-in"></i>
                </span>
                <!-- 图片的下载 -->
                <span
                  v-if="!disabled"
                  class="el-upload-list__item-delete"
                  @click="handleDownload(file)"
                >
                  <i class="el-icon-download"></i>
                </span>
                <!-- 图片的移除 -->
                <span
                  v-if="!disabled"
                  class="el-upload-list__item-delete"
                  @click="handleRemove(file, 'certImageBack')"
                >
                  <i class="el-icon-delete"></i>
                </span>
              </span>
            </div>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="" />
          </el-dialog>
        </el-form-item>
      </div>
    </div>

    <!-- 结算到支付宝 -->
    <div v-if="selectIncomingTypeStatus == 1">
      <!-- 结算到支付宝 -->
      <h6 class="hLabel">默认结算类型</h6>
      <div class="subjectTypeSwitch">
        <!-- 个体 -->
        <div
          :class="[
            sumbitForm.defaultSettleType == 'bankCard'
              ? 'individuality'
              : 'active-individuality'
          ]"
          @click="switchSettlementType('bankCard')"
          >银行卡</div
        >
        <!-- 企业 -->
        <div
          :class="[
            sumbitForm.defaultSettleType == 'alipayAccount'
              ? 'active-enterprise'
              : 'enterprise'
          ]"
          @click="switchSettlementType('alipayAccount')"
          >支付宝</div
        >
      </div>

      <div v-if="sumbitForm.defaultSettleType == 'alipayAccount'">
        <h6 class="hLabel">结算到支付宝</h6>
        <el-form-item label="商户使用服务" prop="serviceList">
          <el-select
            v-model="sumbitForm.serviceList"
            multiple
            @change="verifyChangesFn"
            placeholder="请选择商户使用服务"
          >
            <el-option
              v-for="item in optionsServiceList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算支付宝账号" prop="alipayLogonId">
          <el-input
            show-password
            v-model="sumbitForm.alipayLogonId"
            placeholder="请输入结算支付宝账号"
          ></el-input>
        </el-form-item>
        <el-form-item label="默认结算目标" prop="defaultSettleTarget">
          <el-input
            v-model="sumbitForm.defaultSettleTarget"
            show-password
            :placeholder="
              sumbitForm.defaultSettleType == 'bankCard'
                ? '请输入银行卡号'
                : '请输入支付宝账号登录号'
            "
          ></el-input>
        </el-form-item>
        <el-form-item label="签约支付宝账户" prop="bindingAlipayLogonId">
          <el-input
            show-password
            v-model="sumbitForm.bindingAlipayLogonId"
            placeholder="请输入签约支付宝账户"
          ></el-input>
        </el-form-item>
      </div>
    </div>
    <!-- 结算到银行卡 -->
    <div
      v-if="
        selectIncomingTypeStatus == 0 ||
        sumbitForm.defaultSettleType == 'bankCard'
      "
    >
      <h6 class="hLabel">结算到银行卡</h6>
      <el-form-item label="账户类型" prop="usageType">
        <el-select
          v-model="sumbitForm.usageType"
          placeholder="请选择账户类型"
          @change="verifyChangesFn"
        >
          <el-option
            v-for="item in usageTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="银行卡类型" prop="accountType">
        <el-select
          v-model="sumbitForm.accountType"
          placeholder="请选择银行卡类型"
          @change="verifyChangesFn"
        >
          <el-option
            v-for="item in accountTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="默认结算目标" prop="defaultSettleTarget">
        <el-input
          show-password
          v-model="sumbitForm.defaultSettleTarget"
          :placeholder="
            sumbitForm.defaultSettleType == 'bankCard'
              ? '请输入银行卡号'
              : '请输入支付宝账号登录号'
          "
        ></el-input>
      </el-form-item>
      <el-form-item label="开户银行" prop="accountInstName">
        <el-select
          v-model="sumbitForm.accountInstName"
          placeholder="请选择开户银行"
        >
          <el-option
            v-for="item in accountBankOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <div style="color: #b4b4b4"
          >17家直连银行，请根据开户银行，非17家直连银行，该参数请填写为“其他银行”</div
        >
      </el-form-item>
      <el-form-item label="开户行简称缩写" prop="accountInstId">
        <el-input
          v-model="sumbitForm.accountInstId"
          placeholder="请输入开户行简称缩写"
        ></el-input>
      </el-form-item>
      <el-form-item label="开户支行名" prop="accountBranchName">
        <el-input
          placeholder="请输入开户支行名"
          v-model="sumbitForm.accountBranchName"
        ></el-input>
      </el-form-item>

      <el-form-item label="开户行省市" prop="accountInstCode">
        <regions-select
          v-model="sumbitForm.accountInstCode"
          placeholder="请选择省市区"
          @input="(event) => regionsInput(event, 'accountInstCode')"
        />
      </el-form-item>

      <el-form-item label="开户名称" prop="accountHolderName">
        <el-input
          placeholder="请输入开户名称"
          v-model="sumbitForm.accountHolderName"
        ></el-input>
        <span
          >1、选择经营者个人银行卡时，开户名称必须与身份证姓名一致。<br />
          2、选择对公账户时，开户名称必须与营业执照上的“商户名称”一致。</span
        >
      </el-form-item>
      <el-form-item label="银行卡号" prop="accountNo">
        <el-input
          placeholder="请输入银行账号"
          v-model="sumbitForm.accountNo"
          show-password
        ></el-input>
      </el-form-item>
    </div>
    <div class="drawer__footer">
      <el-button round @click="resetForm('sumbitForm')" type="primary"
        >重置</el-button
      >
      <el-button round type="primary" @click="submit('sumbitForm')"
        >提交</el-button
      >
    </div>
  </div>
</template>
<script>
  import { getToken } from '@/utils/token-util';
  import { userOssSignature } from '@/api/creatCenter/material';
  import UserSearch from './user-search.vue';
  import UserEdit from './user-edit.vue';
  import UserImport from './user-import.vue';
  import EquipmentEdit from './equipment-edit.vue';
  import RegionsSelect from '@/components/RegionsSelect/index.vue';
  import { getRegionLabel } from 'ele-admin/packages/utils/regions';
  import incomingDetails from './incomingDetails.vue';
  import {
    wxGetUploadMediaId,
    wxSumbitMerchantApplyFor,
    zfbGetUploadMediaId,
    zfbMerchantCreate
  } from '@/api/douApi';
  import {
    pageMerchant,
    removeUsers,
    updateUserStatus,
    resetPassword,
    updateUserPassword,
    pageAgencyType
  } from '@/api/oem';
  import {
    certTypeList,
    mccOptions,
    optionsServiceList,
    qualificationTypeOptions,
    accountBankOptions,
    bankAccountTypeOptions,
    usageTypeOptions,
    accountTypeOptions,
    rules,
    list,
    idDocTypeOptions,
    sumbitForm,
    validateLogo,
    storeEntrancePicLogo,
    indoorPicLogo,
    idCardCopyLogo,
    idCardNationalLogo,
    qualificationsLogo,
    outDoorImagesLogo,
    inDoorImagesLogo,
    certImageLogo,
    certImageBackLogo
  } from '../constant/constant';

  import { JSEncrypt } from 'jsencrypt';
  // 导入组件
  import { getDianShu } from '@/api/system/user';
  import ElImageViewer from 'element-ui/packages/image/src/image-viewer';
  import Steps from '@/components/Steps/Steps.vue';
  import axios from 'axios';
  export default {
    name: 'wxIncoming',
    components: {
      incomingDetails,
      UserSearch,
      EquipmentEdit,
      UserEdit,
      UserImport,
      ElImageViewer,
      Steps,
      RegionsSelect
    },
    data() {
      validateLogo;
      storeEntrancePicLogo,
        indoorPicLogo,
        idCardCopyLogo,
        idCardNationalLogo,
        qualificationsLogo,
        outDoorImagesLogo,
        inDoorImagesLogo,
        certImageLogo,
        certImageBackLogo;
      return {
        sumbitForm,
        certTypeList,
        mccOptions,
        optionsServiceList,
        qualificationTypeOptions,
        accountBankOptions,
        bankAccountTypeOptions,
        usageTypeOptions,
        accountTypeOptions,
        rules,
        list,
        idDocTypeOptions,

        // 当前编辑数据
        current: null,
        // 是否显示编辑弹窗
        showEdit: false,
        // 当被限制显示最新的图片
        isImageUrl: false,
        imageUrl: '',
        dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        // 是否弹框
        drawer: false,
        // 代理类型list
        typeList: [],
        // 表格选中数据
        selection: [],
        // 当前编辑数据
        current: null,
        // 是否显示编辑弹窗
        showEdit: false,
        // 是否显示导入弹窗
        showImport: false,
        //是否显示划拨编辑弹窗
        showTransfer: false,
        showViewer: false, // 显示查看器

        // 状态 1 为 微信 2 为支付宝 3为查看详情
        jjstatus: '',

        //   labelPosition right/left/top

        labelPosition: 'top',
        //图片数量
        listLength: 0,
        // 图片文件列表
        fileList: [],

        // 图片列表
        pictureList: [],
        //   表单的收集

        //   选择进件类型 0为微信 1 为支付宝
        selectIncomingTypeStatus: 1,
        //   进件类型 0为微信 1 为支付宝
        incomingTypeStatus: 0,
        //  当前步骤 默认为第一步
        currentStepIndex: 3,
        // 判断当前是否已经进件 1未进件 2 微信进件 3 支付宝进件
        IncomingOrNot: 1,
        //  图片弹框
        dialogVisible: false,

        // 是否显示开户银行联合号 和开户银行全称
        otherBanks: false
      };
    },

    mounted() {
      // 查询可用点数
      getDianShu({
        id: this.$store.state.user.info.merchantId
      })
        .then((msg) => {
          console.log('msg', msg);
          if (msg) {
            this.sumbitForm.merchantId = this.$store.state.user.info.merchantId;
            this.sumbitForm.subordinateAgent = msg.oemId;
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },

    // 路由刷新
    activated() {
      this.init();
    },
    created() {
      this.initRules();
    },
    computed: {
      // 是否开启响应式布局
      styleResponsive() {
        return this.$store.state.theme.styleResponsive;
      },
      classAlipayAccount() {
        return {
          'active-enterprise':
            this.sumbitForm.defaultSettleType === 'alipayAccount',
          enterprise: this.sumbitForm.defaultSettleType !== 'alipayAccount'
        };
      },
      certNoPattern() {
        return this.sumbitForm?.merchantType !== '06'
          ? /^[A-Z0-9]{18}$/
          : /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
      },
      certNoMessage() {
        return this.sumbitForm?.merchantType !== '06'
          ? '营业执照上的注册号/统一社会信用代码格式不对'
          : '身份证输入不合法';
      }
    },

    methods: {
      initRules() {
        console.log(this.sumbitForm.merchantType);
        this.$set(this.rules, 'certNo', [
          { required: true, message: '请填写商户证件编号', trigger: 'blur' },
          {
            pattern:
              this.sumbitForm.merchantType !== '06'
                ? /^[A-Z0-9]{18}$/
                : /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
            message:
              this.sumbitForm.merchantType !== '06'
                ? '营业执照上的注册号/统一社会信用代码格式不对'
                : '身份证输入不合法'
          }
        ]);

        this.$set(this.rules, 'defaultSettleTarget', [
          { required: true, message: '请填写商户证件编号', trigger: 'blur' },
          {
            pattern:
              this.sumbitForm.defaultSettleType == 'bankCard'
                ? /^([1-9])(\d{15}|\d{16}|\d{17}|\d{18})$/
                : /^[a-zA-Z0-9][a-zA-Z0-9._]{4,18}[a-zA-Z0-9]$/,
            message:
              this.sumbitForm.defaultSettleType == 'bankCard'
                ? '请输入银行卡号'
                : '请输入支付宝账号登录号'
          }
        ]);
      },
      // mcc
      handleChangeMcc(value) {
        if (this.sumbitForm.mcc.length) {
          this.$refs.sumbitForm.clearValidate('mcc');
        }
        console.log(value[1]);
      },
      // 切换进件结算类型
      switchSettlementType(settlementType) {
        console.log(settlementType);
        this.sumbitForm.defaultSettleType = settlementType;
        this.initRules();
        this.sumbitForm.defaultSettleTarget = '';
      },
      // 勾选 有效期 那么periodEnd变为长期
      switchCheckbox(checked) {
        this.sumbitForm.checked = checked;
        // 如果勾选 那么营业结束时间变为长期
        if (checked) {
          this.sumbitForm.periodEnd = '';
          // 取消校验
          this.$refs.sumbitForm.clearValidate('periodEnd');
        } else {
          this.sumbitForm.periodEnd = '';
        }
      },
      // 图片的预览
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = !this.dialogVisible;
      },

      handleRemove(file, removeName) {
        let uploadFiles;
        // 进行判断 对不同的数据进行不同的图片的删除
        if (removeName == 'licenseCopy') {
          uploadFiles = this.$refs.pictureUploadLicenseCopy.uploadFiles;
        } else if (removeName == 'storeEntrancePic') {
          uploadFiles = this.$refs.pictureUploadStoreEntrancePic.uploadFiles;
        } else if (removeName == 'indoorPic') {
          uploadFiles = this.$refs.pictureUploadIndoorPic.uploadFiles;
        } else if (removeName == 'qualifications') {
          uploadFiles = this.$refs.pictureUploadQualifications.uploadFiles;
        } else if (removeName == 'idCardCopy') {
          uploadFiles = this.$refs.pictureUploadIdCardCopy.uploadFiles;
        } else if (removeName == 'idCardNational') {
          uploadFiles = this.$refs.pictureUploadIdCardNational.uploadFiles;
        } else if (removeName == 'outDoorImages') {
          uploadFiles = this.$refs.pictureUploadOutDoorImages.uploadFiles;
        } else if (removeName == 'inDoorImages') {
          uploadFiles = this.$refs.pictureUploadInDoorImages.uploadFiles;
        } else if (removeName == 'certImage') {
          uploadFiles = this.$refs.pictureUploadIdCertImage.uploadFiles;
        } else if (removeName == 'certImageBack') {
          uploadFiles = this.$refs.pictureUploadIdCertImageBack.uploadFiles;
        }
        console.log(file, uploadFiles);
        // 获取到该图片的uid 去  this.fileList 去匹配到uid 找到然后去删除掉
        if (this.fileList.length) {
          const uidIndex = this.fileList.findIndex((item, index) => {
            return item.uid == file.uid;
          });
          console.log(uidIndex);
          if (uidIndex !== -1) {
            this.fileList.splice(uidIndex, 1);
          }
        }
        for (let i = 0; i < uploadFiles.length; i++) {
          if (uploadFiles[i]['url'] == file.url) {
            uploadFiles.splice(i, 1);
          }
        }
        console.log(uploadFiles);
      },

      // 图片的下载

      handleDownload(file) {
        window.open(file.url);
      },

      verifyChangesFn(e) {
        console.log(e, this.sumbitForm.qualificationType);
        if (this.sumbitForm.qualificationType) {
          this.$refs.sumbitForm.clearValidate('qualificationType');
        }
        if (this.sumbitForm.idDocType) {
          this.$refs.sumbitForm.clearValidate('idDocType');
        }
        if (this.sumbitForm.bankAccountType) {
          this.$refs.sumbitForm.clearValidate('bankAccountType');
        }
        if (this.sumbitForm.usageType) {
          this.$refs.sumbitForm.clearValidate('usageType');
        }
        if (this.sumbitForm.accountType) {
          this.$refs.sumbitForm.clearValidate('accountType');
        }
        if (this.sumbitForm.serviceList) {
          this.$refs.sumbitForm.clearValidate('serviceList');
        }
      },
      inputFn(e) {
        this.sumbitForm.idCardName = e;
        console.log(e);
      },

      // 清除城市的校验
      regionsInput(value, nameCode) {
        console.log(value, '==============', nameCode);
        if (nameCode == 'licenseCode') {
          this.sumbitForm.provinceCode = value[0];
          this.sumbitForm.cityCode = value[1];
          this.sumbitForm.districtCode = value[2];
        }
        if (nameCode == 'accountInstCode') {
          console.log(getRegionLabel(value));
          const regionLabel = getRegionLabel(value);
          // 开户行所在的省
          this.sumbitForm.accountInstProvince = regionLabel[0];
          // 开户行所在的市
          this.sumbitForm.accountInstCity = regionLabel[1];
        }
        if (this.sumbitForm.bizAddressCode.length) {
          this.$refs.sumbitForm.clearValidate('bizAddressCode');
        }
        if (this.sumbitForm.bankAddressCode.length) {
          this.$refs.sumbitForm.clearValidate('bankAddressCode');
        }
        if (this.sumbitForm.districtCode.length) {
          this.$refs.sumbitForm.clearValidate('districtCode');
        }
        if (this.sumbitForm.licenseCode.length) {
          this.$refs.sumbitForm.clearValidate('licenseCode');
        }
        if (this.sumbitForm.accountInstCode.length) {
          this.$refs.sumbitForm.clearValidate('accountInstCode');
        }
      },
      accountBankFn(item) {
        if (this.sumbitForm.accountBank) {
          this.$refs.sumbitForm.clearValidate('accountBank');
        }
        console.log(item);
        // console.log('http://' + window.location.host.split(':')[0]);
        if (item == '其他银行') {
          this.otherBanks = !this.otherBanks;
        } else {
          this.otherBanks = false;
        }
      },

      //是否要关闭抽屉
      cancelForm() {},
      // 表单重置
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      // 对正则进行校验 ok了进行下一步
      submit(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.pictureList = [];
            // 特殊资质图片
            this.sumbitForm.qualificationsMediaId = [];
            // 线下场所门头照片
            this.sumbitForm.storeEntrancePicMediaId = [];
            // 线下场所内部照片
            this.sumbitForm.indoorPicMediaId = [];
            // 身份证人像面照片
            this.sumbitForm.idCardCopyMediaId = '';
            // 身份证国徽面照片
            this.sumbitForm.idCardNationalMediaId = '';

            //  阿里 门头照OssKey
            this.sumbitForm.outDoorImagesOssKey = [];
            //  阿里 证件反面图片OssKey
            this.sumbitForm.certImageBackOssKey = '';
            //  阿里 证件正面图片OssKey
            this.sumbitForm.certImageOssKey = '';
            //  阿里 办公环境osskey
            this.sumbitForm.inDoorImagesOssKey = [];
            this.wxuploadBj();
            //   this.zfbuploadBj();
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },

      async zfbuploadBj() {
        if (this.fileList.length < 1) {
          console.log('请选择文件后提交');
          this.$message.error('请选择文件后提交');
          return;
        }
        this.data = await userOssSignature();
        for (let i = 0; i < this.fileList.length; i++) {
          let file = this.fileList[i].raw;
          let imgType = this.fileList[i].imgType;
          let filename = file.name;
          let markIndex = filename.lastIndexOf('.');
          let suffix = filename.substring(markIndex);
          let date = new Date().getTime();
          // 构建请求参数
          let param = new FormData();
          param.append('key', this.data.dir + imgType + '/' + date + suffix);
          param.append('policy', this.data.policy);
          param.append('OSSAccessKeyId', this.data.accessId);
          param.append('success_action_status', '200');
          // param.append("callback",  this.data.callback)     //回调（not)
          param.append('signature', this.data.signature);
          param.append('file', file, file.name);
          param.append('success_action_status', '200');
          let config = {
            headers: {
              'Access-Control-Allow-Origin': '*',
              'x-oss-callback-Authorization': getToken()
            }
          };
          console.log('suffix', suffix);

          let res = await axios.post(this.data.host, param, config);
          let url;
          if (res.status == 200) {
            url = this.data.host + '/' + imgType + '/' + date + suffix;

            console.log('上传图片成功=======', res);
            console.log('this.data.host', url);

            // 清空已上传的文件列表（该方法不支持在 before-upload 中调用）
            // this.$refs['upload'].clearFiles()
            // this.fileList = [];
            // this.registerMedias(url, type);

            this.pictureList.push(url);
          } else {
            this.$message.error('上传失败');
          }
          //  获取到id
          const result = await zfbGetUploadMediaId([url]);

          console.log(result);

          // 当个MediaId 是字符串 多个是数组  营业执照和正反面的身份证是字符串格式其他的都是数组格式
          if (result.data.code == 200) {
            if (imgType == 'licenseCopy') {
              // 营业执照照片
              this.sumbitForm.licenseCopyMediaId = result.data.data.imageId;
              console.log(this.sumbitForm.licenseCopyMediaId);
            } else if (imgType == 'outDoorImages') {
              // 门头照片
              this.sumbitForm.outDoorImagesOssKey.push(
                result.data.data.imageId
              );
              // console.log(this.sumbitForm.storeEntrancePic)
            } else if (imgType == 'inDoorImages') {
              // 办公环境
              this.sumbitForm.inDoorImagesOssKey.push(result.data.data.imageId);
            } else if (imgType == 'certImage') {
              // 正面身份证头像
              this.sumbitForm.certImageOssKey = result.data.data.imageId;
            } else if (imgType == 'certImageBack') {
              // 反面身份证头像
              this.sumbitForm.certImageBackOssKey = result.data.data.imageId;
            }
          }
        }

        setTimeout(async () => {
          //  对图片进行分类
          console.log(this.pictureList);

          // 获取到不同的图片地址然后放到from表单中
          // // 营业执照照片
          // let licenseCopy = this.pictureList.filter((url) =>
          //   url.includes('licenseCopy')
          // );

          // this.sumbitForm.licenseCopy = licenseCopy.join(',');
          // 线下场所门头照片
          let outDoorImagesPic = this.pictureList.filter((url) =>
            url.includes('outDoorImages')
          );
          this.sumbitForm.outDoorImages = outDoorImagesPic.join(',');
          // 办公环境
          let inDoorImagesPic = this.pictureList.filter((url) =>
            url.includes('inDoorImages')
          );
          this.sumbitForm.inDoorImages = inDoorImagesPic.join(',');

          // 身份证正面头像
          let certImagePic = this.pictureList.filter(
            (url) => url.includes('certImage') && !url.includes('certImageBack')
          );
          console.log(certImagePic);
          this.sumbitForm.certImage = certImagePic.join(',');
          // 身份证反面头像
          let certImageBackPic = this.pictureList.filter((url) =>
            url.includes('certImageBack')
          );
          this.sumbitForm.certImageBack = certImageBackPic.join(',');

          // 把submitFrom 转化为  {merchantsapplyfor:{}，businesslicense：{}}

          let params = {
            alipaymerchant: {
              // mcc
              mcc: this.sumbitForm.mcc[1],
              // 商户类型
              merchantType: this.sumbitForm.merchantType,
              // 商户名称
              name: this.sumbitForm.name,
              // 商户别名
              aliasName: this.sumbitForm.aliasName,

              // 商户证件编号
              certNo: this.sumbitForm.certNo,
              // 商户证件类型
              certType: this.sumbitForm.certType,
              // 法人名称
              legalName: this.sumbitForm.legalName,
              // 法人身份证号
              legalCertNo: this.sumbitForm.legalCertNo,
              // 联系人姓名
              contactName: this.sumbitForm.contactName,
              // 联系人电话
              contactMobile: this.sumbitForm.contactMobile,
              // 商户使用服务
              service: this.sumbitForm.serviceList.join(','),
              // 商户使用服务  String[]
              serviceList: this.sumbitForm.serviceList,
              // 结算支付宝账号
              alipayLogonId: this.sumbitForm.alipayLogonId,
              // 营业执照名称
              certName: this.sumbitForm.certName,
              // 签约支付宝账户
              bindingAlipayLogonId: this.sumbitForm.bindingAlipayLogonId,
              // 默认结算类型
              defaultSettleType: this.sumbitForm.defaultSettleType,
              // 默认结算目标
              defaultSettleTarget: this.sumbitForm.defaultSettleTarget,
              // 办公环境
              inDoorImages: this.sumbitForm.inDoorImages,
              // 办公环境OssKey
              inDoorImagesOssKey: this.sumbitForm.inDoorImagesOssKey,
              // 商户证件图片url
              certImage: this.sumbitForm.certImage,
              // 商户证件图片urlOssKey
              certImageOssKey: this.sumbitForm.certImageOssKey,
              // 证件反面图片
              certImageBack: this.sumbitForm.certImageBack,
              // 证件反面图片OssKey
              certImageBackOssKey: this.sumbitForm.certImageBackOssKey,
              // 城市编码
              cityCode: this.sumbitForm.cityCode,
              // 区县编码
              districtCode: this.sumbitForm.districtCode,
              // 营业执照地址
              address: this.sumbitForm.address,
              // 省份编码
              provinceCode: this.sumbitForm.provinceCode,
              // 门头照
              outDoorImages: this.sumbitForm.outDoorImages,
              // 门头照OssKey
              outDoorImagesOssKey: this.sumbitForm.outDoorImagesOssKey
            },
            settlecardinfo: {
              // 卡户名
              accountHolderName: this.sumbitForm.accountHolderName,
              // 银行卡号
              accountNo: this.sumbitForm.accountNo,
              // 开户行所在地-省
              accountInstProvince: this.sumbitForm.accountInstProvince,
              // 开户行所在地-市
              accountInstCity: this.sumbitForm.accountInstCity,
              // 开户支行名
              accountBranchName: this.sumbitForm.accountBranchName,
              // 账号使用类型
              usageType: this.sumbitForm.usageType,
              // 银行卡类型
              accountType: this.sumbitForm.accountType,
              // 银行名称
              accountInstName: this.sumbitForm.accountInstName,
              // 开户行简称缩写
              accountInstId: this.sumbitForm.accountInstId
            }
          };

          console.log(params);
          const res = await zfbMerchantCreate(params);
          console.log(res);
        }, 2000);
      },
      async wxuploadBj() {
        if (this.fileList.length < 1) {
          console.log('请选择文件后提交');
          this.$message.error('请选择文件后提交');
          return;
        }
        this.data = await userOssSignature();
        for (let i = 0; i < this.fileList.length; i++) {
          let file = this.fileList[i].raw;
          let imgType = this.fileList[i].imgType;
          let filename = file.name;
          let markIndex = filename.lastIndexOf('.');
          let suffix = filename.substring(markIndex);
          let date = new Date().getTime();
          // 构建请求参数
          let param = new FormData();
          param.append('key', this.data.dir + imgType + '/' + date + suffix);
          param.append('policy', this.data.policy);
          param.append('OSSAccessKeyId', this.data.accessId);
          param.append('success_action_status', '200');
          // param.append("callback",  this.data.callback)     //回调（not)
          param.append('signature', this.data.signature);
          param.append('file', file, file.name);
          param.append('success_action_status', '200');
          let config = {
            headers: {
              'Access-Control-Allow-Origin': '*',
              'x-oss-callback-Authorization': getToken()
            }
          };
          console.log('suffix', suffix);

          let res = await axios.post(this.data.host, param, config);
          let url;
          if (res.status == 200) {
            url = this.data.host + '/' + imgType + '/' + date + suffix;

            console.log('上传图片成功=======', res);
            console.log('this.data.host', url);

            // 清空已上传的文件列表（该方法不支持在 before-upload 中调用）
            // this.$refs['upload'].clearFiles()
            // this.fileList = [];
            // this.registerMedias(url, type);

            this.pictureList.push(url);
          } else {
            this.$message.error('上传失败');
          }
          //  获取到id
          //  const result
          // if () {
          //   result = await zfbGetUploadMediaId([url]);
          // } else {
          const result = await wxGetUploadMediaId([url]);
          // }

          console.log(result);

          // 当个MediaId 是字符串 多个是数组  营业执照和正反面的身份证是字符串格式其他的都是数组格式
          if (result.data.code == 200) {
            if (imgType == 'licenseCopy') {
              // 营业执照照片
              this.sumbitForm.licenseCopyMediaId = result.data.data.mediaId;
              console.log(this.sumbitForm.licenseCopyMediaId);
            } else if (imgType == 'storeEntrancePic') {
              // 门头照片
              this.sumbitForm.storeEntrancePicMediaId.push(
                result.data.data.mediaId
              );
              // console.log(this.sumbitForm.storeEntrancePic)
            } else if (imgType == 'indoorPic') {
              // 办公环境
              this.sumbitForm.indoorPicMediaId.push(result.data.data.mediaId);
            } else if (imgType == 'qualifications') {
              // 特殊资历
              this.sumbitForm.qualificationsMediaId.push(
                result.data.data.mediaId
              );
            } else if (imgType == 'idCardCopy') {
              // 正面身份证头像
              this.sumbitForm.idCardCopyMediaId = result.data.data.mediaId;
            } else if (imgType == 'idCardNational') {
              // 反面身份证头像
              this.sumbitForm.idCardNationalMediaId = result.data.data.mediaId;
            }
          }
        }

        setTimeout(async () => {
          //  对图片进行分类
          console.log(this.pictureList);

          // 获取到不同的图片地址然后放到from表单中
          // 营业执照照片
          let licenseCopy = this.pictureList.filter((url) =>
            url.includes('licenseCopy')
          );

          this.sumbitForm.licenseCopy = licenseCopy.join(',');
          // 线下场所门头照片
          let storeEntrancePic = this.pictureList.filter((url) =>
            url.includes('storeEntrancePic')
          );
          this.sumbitForm.storeEntrancePic = storeEntrancePic.join(',');
          // 办公环境
          let indoorPic = this.pictureList.filter((url) =>
            url.includes('indoorPic')
          );
          this.sumbitForm.indoorPic = indoorPic.join(',');
          // 特殊资质图片
          let qualifications = this.pictureList.filter((url) =>
            url.includes('qualifications')
          );
          this.sumbitForm.qualifications = qualifications.join(',');
          // 身份证正面头像
          let idCardCopy = this.pictureList.filter((url) =>
            url.includes('idCardCopy')
          );
          this.sumbitForm.idCardCopy = idCardCopy.join(',');
          // 身份证反面头像
          let idCardNational = this.pictureList.filter((url) =>
            url.includes('idCardNational')
          );
          this.sumbitForm.idCardNational = idCardNational.join(',');

          // 把submitFrom 转化为  {merchantsapplyfor:{}，businesslicense：{}}

          let params = {
            merchantsapplyfor: {
              merchantId: this.sumbitForm.merchantId,
              subordinateAgent: this.sumbitForm.subordinateAgent,
              mobilePhone: this.sumbitForm.mobilePhone,
              contactEmail: this.sumbitForm.contactEmail,
              subjectType: this.sumbitForm.subjectType,
              idDocType: this.sumbitForm.idDocType,
              idCardCopy: this.sumbitForm.idCardCopy,
              // 身份证正面
              idCardCopyMediaId: this.sumbitForm.idCardCopyMediaId,
              idCardNational: this.sumbitForm.idCardNational,
              // 身份证反面
              idCardNationalMediaId: this.sumbitForm.idCardNationalMediaId,

              idCardName: this.sumbitForm.idCardName,
              idCardNumber: this.sumbitForm.idCardNumber,
              idCardAddress: this.sumbitForm.idCardAddress,
              cardPeriodBegin: this.sumbitForm.cardPeriodBegin,
              cardPeriodEnd: this.sumbitForm.cardPeriodEnd
            },
            businesslicense: {
              licenseCopy: this.sumbitForm.licenseCopy,
              // 营业执照 MediaId
              licenseCopyMediaId: this.sumbitForm.licenseCopyMediaId,
              licenseNumber: this.sumbitForm.licenseNumber,
              merchantName: this.sumbitForm.merchantName,
              legalPerson: this.sumbitForm.legalPerson,
              licenseAddress: this.sumbitForm.licenseAddress,
              periodBegin: this.sumbitForm.periodBegin,
              periodEnd: this.sumbitForm.periodEnd
                ? this.sumbitForm.periodEnd
                : '长期'
            },
            bankaccount: {
              bankAccountType: this.sumbitForm.bankAccountType,
              accountName: this.sumbitForm.accountName,
              accountBank: this.sumbitForm.accountBank,
              bankBranchId: this.sumbitForm.bankBranchId,
              bankName: this.sumbitForm.bankName,
              accountNumber: this.sumbitForm.accountNumber,
              bankAddressCode: this.bankAddressCode()
            },
            businessinfo: {
              merchantShortname: this.sumbitForm.merchantShortname,
              servicePhone: this.sumbitForm.servicePhone,

              bizStoreName: this.sumbitForm.bizStoreName,
              bizAddressCode: this.bizAddressCode(),
              bizStoreAddress: this.sumbitForm.bizStoreAddress,
              storeEntrancePic: this.sumbitForm.storeEntrancePic,
              // 门头照片 MediaId
              storeEntrancePicMediaId: this.sumbitForm.storeEntrancePicMediaId,
              indoorPic: this.sumbitForm.indoorPic,
              // 线下场所内部照片
              indoorPicMediaId: this.sumbitForm.indoorPicMediaId
            },
            settlement: {
              settlementId: this.sumbitForm.settlementId,
              qualificationType: this.sumbitForm.qualificationType,
              qualifications: this.sumbitForm.qualifications,
              // 特殊资质 MediaId
              qualificationsMediaId: this.sumbitForm.qualificationsMediaId,
              activitiesRate: this.sumbitForm.activitiesRate
            }
          };

          console.log(params);

          const MerchantApplyForRes = await wxSumbitMerchantApplyFor(params);
          console.log(MerchantApplyForRes);
        }, 2000);
      },
      // 获取第在的code编码
      bankAddressCode() {
        if (this.sumbitForm.bankAddressCode) {
          const res =
            this.sumbitForm.bankAddressCode?.[
              this.sumbitForm.bankAddressCode.length - 1
            ];
          return res;
        }
      },

      bizAddressCode() {
        if (this.sumbitForm.bankAddressCode) {
          const res =
            this.sumbitForm.bizAddressCode?.[
              this.sumbitForm.bankAddressCode.length - 1
            ];
          return res;
        }
      },

      // 提交图片之前的一些限制
      beforeAvatarUpload(file) {
        // const isJPG = file.type === 'image/jpeg';
        console.log(file);
        const isJPG = file.raw.type;
        const isLt2M = file.raw.size / 1024 / 1024 < 2;

        const extension1 = file.raw.type === 'image/jpg';
        const extension2 = file.raw.type === 'image/jpeg';
        const extension3 = file.raw.type === 'image/png';
        const extension4 = file.raw.type === 'image/bmp';
        if (!extension1 && !extension2 && !extension3 && !extension4) {
          this.$message.error('请上传jpg 、png、jpeg 类型图片!');
        }
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      },
      // 这里对图片上传以后当图片数量大于0则去除校验提示
      handleFileChange(file, fileList, name) {
        if (file.status !== 'ready') return;
        const isPass = this.beforeAvatarUpload(file);
        console.log(isPass);
        if (!isPass) {
          this.handleRemove(file, name);
          return;
        }

        //图片上传后
        console.log(file);
        this.listLength = fileList.length;
        if (name == 'licenseCopy') {
          this.sumbitForm.licenseCopy = file.name;
        } else if (name == 'qualifications') {
          this.sumbitForm.qualifications = file.name;
        } else if (name == 'storeEntrancePic') {
          this.sumbitForm.storeEntrancePic = file.name;
        } else if (name == 'indoorPic') {
          this.sumbitForm.indoorPic = file.name;
        } else if (name == 'idCardCopy') {
          this.sumbitForm.idCardCopy = file.name;
        } else if (name == 'idCardNational') {
          this.sumbitForm.idCardNational = file.name;
        } else if (name == 'inDoorImages') {
          this.sumbitForm.inDoorImages = file.name;
        } else if (name == 'certImage') {
          this.sumbitForm.certImage = file.name;
        } else if (name == 'certImageBack') {
          this.sumbitForm.certImageBack = file.name;
        } else if (name == 'outDoorImages') {
          this.sumbitForm.outDoorImages = file.name;
        }

        fileList.forEach((item) => {
          item.imgType = name;
        });
        let files = fileList[fileList.length - 1];
        this.fileList.push(files);
        console.log(file, fileList, this.fileList, name);
        if (this.listLength > 0) {
          // 这里还需要判断一下图片的类型 只有有当前的类型才去除验证
          const fileObject = this.fileList.find((item, index) => {
            return item.imgType == name;
          });
          this.$refs.sumbitForm.clearValidate(fileObject.imgType); //当图片数量大于0则去除校验提示
        }
      },
      //  图片上传个数超过限制
      exceedFn() {
        this.$message({
          message: '图片上传已达到上限,请删除后再上传',
          type: 'warning'
        });
      },

      // 营业执照有效时间
      businessLicense(timeArr, periodName) {
        console.log(timeArr, periodName);
        //   开始时间
        if (periodName == 'periodBegin') {
          this.sumbitForm.periodBegin = timeArr;
        } else {
          //   结束时间
          this.sumbitForm.periodEnd = timeArr;
        }
      },
      // 身份证有效时间
      IDCardDateRange(timeArr) {
        console.log(timeArr);
        //   开始时间
        this.sumbitForm.cardPeriodBegin = timeArr[0];
        //   结束时间
        this.sumbitForm.cardPeriodEnd = timeArr[1];
      },
      // 点击按钮预览图片
      onPreview() {
        this.showViewer = true;
      },
      // 关闭查看器
      closeViewer() {
        this.showViewer = false;
      },

      // 查询代理类型
      init() {
        pageAgencyType({
          deleted: 0,
          limit: 10,
          page: 1,
          types: 1
        })
          .then((data) => {
            this.typeList = data.list;
            console.log('data==', data);
          })
          .catch((e) => {
            this.$message.error(e.message);
          });
      },

      // 返回上一页
      previousPage() {
        this.currentStepIndex = this.currentStepIndex - 1;
        if (this.currentStepIndex == 1) {
          this.currentStepIndex == 1;
        }
        console.log(this.currentStepIndex);
      },

      // 打开微信进件
      openWeInbound(index) {
        this.drawer = true;
        this.jjstatus = index;
      },

      /* 表格数据源 */
      datasource({ page, limit, where, order }) {
        //   console.log(where, order);
        if (!where.deleted) where.deleted = 0;
        return pageMerchant({ ...where, ...order, page, limit, oemType: 1 });
      },
      /* 刷新表格 */
      reload(where) {
        console.log('where', where);
        this.$refs.table.reload({ page: 1, where: where });
      },
      modifyRate() {
        this.current = null;
        this.showEdit = true;
      },
      /* 打开划拨编辑弹窗 */
      openTransfer(row) {
        this.current = row;
        this.showTransfer = true;
      },
      /* 打开导入弹窗 */
      openImport() {
        this.showImport = true;
      },
      /* 删除 */
      remove(row) {
        const loading = this.$loading({ lock: true });
        removeUsers({ ids: [row.id] })
          .then((msg) => {
            loading.close();
            this.$message.success(msg);
            this.reload();
          })
          .catch((e) => {
            loading.close();
            this.$message.error(e.message);
          });
      },
      /*重置密码*/
      resets(row) {
        const loading = this.$loading({ lock: true });
        console.log('row', row);
        resetPassword({ id: row.id })
          .then((msg) => {
            loading.close();
            this.$message.success(msg);
            this.reload();
          })
          .catch((e) => {
            loading.close();
            this.$message.error(e.message);
          });
      },
      /* 批量删除 */
      removeBatch() {
        if (!this.selection.length) {
          this.$message.error('请至少选择一条数据');
          return;
        }
        this.$confirm('确定要删除选中的代理吗?', '提示', {
          type: 'warning'
        })
          .then(() => {
            const loading = this.$loading({ lock: true });
            removeUsers({ ids: this.selection.map((d) => d.id) })
              .then((msg) => {
                loading.close();
                this.$message.success(msg);
                this.reload();
              })
              .catch((e) => {
                loading.close();
                this.$message.error(e.message);
              });
          })
          .catch(() => {});
      },
      /* 更改状态 */
      editStatus(row) {
        const loading = this.$loading({ lock: true });
        updateUserStatus(row.id, row.status)
          .then((msg) => {
            console.log('msg=======', msg);
            loading.close();
            this.$message.success(
              row.status == 1 ? '启用成功！' : '冻结成功！'
            );
          })
          .catch((e) => {
            loading.close();
            row.status = !row.status ? 1 : 0;
            this.$message.error(e);
          });
      },
      // 切换 0 为 个人 1 为企业
      switchType(index) {
        if (this.selectIncomingTypeStatus == 0) {
          this.sumbitForm.subjectType = index;
          if (index == 'SUBJECT_TYPE_INDIVIDUAL') {
            //   个人 719
            this.sumbitForm.settlementId = '746';
          } else {
            this.sumbitForm.settlementId = '716';
          }
        } else {
          this.sumbitForm.merchantType = index;
          // 01：企业；cert_type填写201（营业执照）；cert_no填写营业执照号；
          // 06：个人商户：cert_type填写100（个人身份证）；cert_no填写个人身份证号码；
          // 07：个体工商户：cert_type填写201（营业执照）；cert_no填写营业执照编号；

          if (index == '01') {
            this.sumbitForm.certType = this.certTypeList.businessLicense;
          } else if ('06') {
            this.sumbitForm.certType = this.certTypeList.personalIDCard;
          } else if ('07') {
            this.sumbitForm.certType = this.certTypeList.businessLicense;
          }
        }
        this.initRules();
      },
      // 切换 0 为 微信 1 为支付宝
      incomingType(index) {
        this.selectIncomingTypeStatus = index;
        if (index == 1) {
          this.IncomingOrNot = 1;
        }
        if (index == 0) {
          this.IncomingOrNot = 1;
        }
      }
    }
  };
</script>

<style lang="less" scoped>
  /deep/.el-cascader--medium {
    width: 100%;
  }
  /deep/.el-select {
    min-width: 100%;
  }
  .zfbIncoming() {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 283px;
    height: 90px;
    box-sizing: border-box;
    position: relative;

    .zfbHLabel {
      margin: 10px 0 20px;
      font-weight: 700;
      &::before {
        content: url('../../../../static/svg/zfbIcon.svg');
        display: inline-block;
        vertical-align: middle;
        margin-top: 10px;
        margin-right: 10px;
      }
    }
    .zfbText {
      .zfbTextFontSize {
        color: #000;
        margin-bottom: 5px;
        font-size: 20px;
      }
      .activr-zfbTextFontSize {
        color: #0077e5;
        margin-bottom: 5px;
        font-size: 20px;
      }
    }
  }

  .wxIncoming() {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 283px;
    height: 90px;
    position: relative;
    box-sizing: border-box;
    .wxHLabel {
      margin: 15px 0 20px;
      font-weight: 700;
      &::before {
        content: url('../../../../static/svg/wxIcon.svg');
        display: inline-block;
        vertical-align: middle;
        margin-top: 10px;
        margin-right: 10px;
      }
    }

    .wxText {
      .wxTextFontSize {
        color: #000;

        font-size: 20px;
        margin-bottom: 5px;
      }
      .activr-wxTextFontSize {
        color: #0077e5;
        margin-bottom: 5px;
        font-size: 20px;
      }
    }
  }

  .incomingTypeSwitch() {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    .wxIncoming {
      margin-right: 25px;
      .wxIncoming();
      &::before {
      }
    }

    .active-wxIncoming {
      margin-right: 25px;
      background: #e9f7ff;
      border-radius: 10px;
      border: 1px solid #1890ff;
      .wxIncoming();
      &::before {
        content: url('../../../../static/check.png');
        position: absolute;
        width: 25px;
        height: 14px;
        border-radius: 10px 0px;
        border: 1px solid #1890ff;
        background: #1890ff;
        right: 0;
        bottom: 0;
        line-height: 17px;
        text-align: center;
      }
    }
    .zfbIncoming {
      //   background: #e9f7ff;
      .zfbIncoming();
      &::before {
      }
    }
    .active-zfbIncoming {
      background: #e9f7ff;
      border-radius: 10px;
      border: 1px solid #1890ff;
      .zfbIncoming();
      &::before {
        content: url('../../../../static/check.png');
        position: absolute;
        width: 25px;
        height: 14px;
        border-radius: 10px 0px;
        border: 1px solid #1890ff;
        background: #1890ff;
        right: 0;
        bottom: 0;
        line-height: 17px;
        text-align: center;
      }
    }
  }
  .el-row {
    padding: 30px;
  }
  .el-row-active {
    padding: 30px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .zfb-purple {
    .zfbHLabel {
      margin: 15px 0 20px;
      font-weight: 700;
      &::before {
        content: url('../../../../static/svg/zfbIcon.svg');
        display: inline-block;
        vertical-align: middle;

        margin-right: 5px;
      }
    }

    .fromSubmitOne {
      .hLabel {
        margin: 15px 0 20px;
        font-weight: 700;
        &::before {
          content: '';
          display: inline-block;
          vertical-align: top;

          margin-right: 5px;
          height: 23px;
          width: 6px;
          background-color: #1e6ceb;
        }
      }
      .businessLicenseTime {
        display: flex;

        justify-content: flex-start;
        align-items: center;
      }
      /deep/.el-range-editor--medium.el-input__inner {
        width: 600px !important;
      }
      .ruleForm {
        /deep/.el-form-item__label {
          color: #000;
        }
        /deep/.el-form-item {
          max-width: 737px;
          min-width: 245px;
        }
        /deep/ .el-upload--picture-card {
          line-height: 178px;
        }
        span {
          color: #b4b4b4;
        }

        .subjectTypeSwitch {
          display: flex;
          height: 36px;
          line-height: 36px;
          justify-content: flex-start;
          border-radius: 3%;
          width: 160px;

          background-color: #fff;
          border: 1px solid #d9d9d9;
          text-align: center;
          .enterprise {
            //   overflow: hidden;
            background-color: #fff;
            width: 40%;
          }
          .individuality {
            color: #fff;
            background-color: #289aff;

            width: 60%;
          }
          .active-enterprise {
            width: 40%;
            color: #fff;
            background-color: #289aff;
          }
          .active-individuality {
            color: #606266;
            background-color: #fff;
            width: 60%;
          }
        }
        .incomingTypeSwitch {
          .incomingTypeSwitch();
        }

        .active-incomingTypeSwitch {
          .incomingTypeSwitch();
          padding-bottom: 30px;
          border-bottom: 1px solid #dadada;
        }
      }
      .drawer__footer {
        max-width: 737px;
        min-width: 337px;

        display: flex;
        justify-content: space-between;
      }
    }
  }
</style>
